package hero.antlr2;

import org.antlr.runtime.ANTLRFileStream;
import hero.antlr.SimplestLexer;
import hero.antlr.SimplestParser;
import org.antlr.runtime.tree.CommonTreeNodeStream;
import org.antlr.runtime.tree.CommonTree;
import org.antlr.runtime.CommonTokenStream;

public class Test {

    public static void main(String[] args) {
        System.out.println("shit");
        test2();
    }
    public static void test2() {
        try {
            System.out.println("finished");
            ANTLRFileStream fs = new ANTLRFileStream("test.txt");

            SimplestLexer lexer = new SimplestLexer(fs); 
            CommonTokenStream tokens = new CommonTokenStream(lexer); 
            SimplestParser parser = new SimplestParser(tokens); 

            CommonTree t = (CommonTree)parser.prog().getTree();
            CommonTreeNodeStream nodes = new CommonTreeNodeStream(t); 
            TreeWalker walker = new TreeWalker(nodes); 
            walker.prog();
            System.out.println("finished");
            
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}

